import java.util.*;

public class Program4
{
	public void convertToBaseTwo(int x)
	{
		int y = x;
		int number = 0;
		int denominator = 1;
		String answer = "";
		
		for(int i = 1; i < Integer.MAX_VALUE;)
		{
			if(x > i)
			{
				i *= 2;
				continue;
            
			}
			else
			{
				denominator = i / 2;
				break;
			}

		}
		
		for(int i = denominator; i > 0;)
		{
			number = x / i;
			answer += number;
			x -= (i * number);
			i /= 2;
		}
		System.out.println(y + " in base 2 is " + answer);
	}
	
	public void convertToBaseEight(int x)
	{
		int y = x;
		int number = 0;
		int denominator = 1;
		String answer = "";
		
		for(int i = 1; i < Integer.MAX_VALUE;)
		{
			if(x > i)
			{
				i *= 8;
				continue;
			}
			else
			{
				denominator = i / 8;
				break;
			}

		}
		
		for(int i = denominator; i > 0;)
		{
			number = x / i;
			answer += number;
			x -= (i * number);
			i /= 8;
		}
		System.out.println(y + " in base 8 is " + answer);
	}
	
	public void convertToBaseSixteen(int x)
	{
		int y = x;
		int number = 0;
		int denominator = 1;
		String answer = "";
		
		for(int i = 1; i < Integer.MAX_VALUE;)
		{
			if(x > i)
			{
				i *= 16;
				continue;
			}
			else
			{
				denominator = i / 16;
				break;
			}

		}
		
		for(int i = denominator; i > 0;)
		{
			number = x / i;
			
			switch(number)
			{
			case 10:
				answer += 'A';
				break;
			case 11:
				answer += 'B';
				break;
			case 12:
				answer += 'C';
				break;
			case 13:
				answer += 'D';
				break;
			case 14:
				answer += 'E';
				break;
			case 15:
				answer += 'F';
				break;
				
			default:
				answer += number;
				break;
			}
			
			x -= (i * number);
			i /= 16;
		}
		System.out.println(y + " in base 16 is " + answer);
	}

	public static void main(String[] args) 
	{
		Program4 p = new Program4();
		Scanner keyboard = new Scanner(System.in);
		int input;
		
		System.out.print("Please enter a number to convert: ");
		input = keyboard.nextInt();
		
		p.convertToBaseTwo(input);
		p.convertToBaseEight(input);
		p.convertToBaseSixteen(input);
	}

}
